import React from "react";
import { Navigate } from 'react-router-dom'
// 引入路由组件-懒加载
// 二级
const Home = React.lazy(() => import("../views/home"));
const List = React.lazy(() => import("../views/list"));
const Set = React.lazy(() => import("../views/set"));

const Detail = React.lazy(() => import("../views/detail"));

// 一级
const Login = React.lazy(() => import("../views/login"));
const MainLayout = React.lazy(() => import("../views/mainLayout"));

// 路由表
export const ROUTER_LIST = [
  {
    path: "/home",
    meta: {
      title: "首页",
    },
    element: (
      <MainLayout>
        <Home></Home>
      </MainLayout>
    ),
  },
  {
    path: "/list",
    meta: {
      title: "列表",
    },
    element: (
      <MainLayout>
        <List></List>
      </MainLayout>
    ),
  },
  {
    path: "/set",
    meta: {
      title: "设置",
      roles: ['admin']
    },
    element: (
      <MainLayout>
        <Set></Set>
      </MainLayout>
    ),
  },
  {
    path: "/login",
    meta: {
      title: "登录",
      hidden: true,
    },
    element: <Login></Login>,
  },
  {
    path: "/detail",
    meta: {
      hidden: true,
      title: "详情",
    },
    element: <Detail></Detail>,
  },
  {
    path: '/',
    element: <Navigate to="/home"></Navigate>,
    meta: {
      hidden: true
    }
  }
];
